﻿using System;
using System.Collections.Generic;

namespace HappyTemplate
{
	public class PropertyNotFoundException : ApplicationException
	{
		private readonly string _fieldName;

		public string FieldName { get { return _fieldName;  } }

		public PropertyNotFoundException(string fieldName)
			: base(String.Format("Field \"{0}\" not found.", fieldName))
		{
			_fieldName = fieldName;
		}

	}

	public class TemplateObject : Dictionary<string, object>
	{
		private string _defaultValue;

		public string DefaultValue
		{
			get { return _defaultValue; }
			set { _defaultValue = value; }
		}

		public TemplateObject()
		{
			_defaultValue = null;
		}

		public TemplateObject(string defaultValue)
		{
			_defaultValue = defaultValue;
		}
		public override string ToString()
		{
			return _defaultValue;
		}
		//public object this[string name]
		//{ 
		//    get
		//    {
		//        object retval;

		//        if (!_properties.TryGetValue(name, out retval))
		//            throw new PropertyNotFoundException(name);

		//        return _properties[name];
		//    } 
		//    set
		//    {
		//        _properties[name] = value;
		//    }
		//}


	}
}
